<template>
	<!-- <div v-cloak class="aui-wrapper aui-page__iframe">
        <div class="aui-content__wrapper">
            <div class="aui-content">
                <el-card shadow="never" class="aui-card--fill">
                    <div class="mod-lswms__allocationstrategydetail"> -->
	<el-dialog v-model="visible" title="明细 " :close-on-click-modal='false' :close-on-press-escape='false'
		:fullscreen='true'>
		<el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
			<!-- <el-form-item>
                            <el-input v-model="dataForm.id" placeholder="id" clearable></el-input>
                          </el-form-item> -->
			<!-- <el-form-item>
                            <el-button @click="getDataList()">查询</el-button>
                          </el-form-item> -->
			<el-form-item>
				<el-button type="primary" @click="addOrUpdateallocationstrategydetailHandleFn()"  size="small" v-if="hasPermission('lswms:allocationstrategy:save')" >新增</el-button>
			</el-form-item>
			<el-form-item>
				<el-button type="danger" @click="deleteHandle()"  size="small" v-if="hasPermission('lswms:allocationstrategy:delete')">删除</el-button>
			</el-form-item>
			<!-- <el-form-item>
                            <el-button type="info" @click="exportHandle()">导出</el-button>
                          </el-form-item> -->
		</el-form>
		<el-table v-loading="dataListLoading" :data="dataList" border @selection-change="dataListSelectionChangeHandle"
			@sort-change="dataListSortChangeHandle" style="width: 100%;">
			<el-table-column type="selection" header-align="center" align="center" width="50"></el-table-column>
			<!-- <el-table-column prop="id" label="序号"  header-align="center"
                                           align="center"></el-table-column> -->
			<!-- <el-table-column prop="strategykey" label="分配策略号"  header-align="center"
                                           align="center"></el-table-column> -->
			<!--  <el-table-column prop="line" label="行号"  header-align="center"
                                           align="center"></el-table-column> -->
			<el-table-column prop="orderline" label="步骤号" header-align="center" align="center"></el-table-column>
			<!-- <el-table-column prop="strategytype" label="分配类型" header-align="center" align="center"></el-table-column> -->
			<el-table-column prop="overallocatepicks" label="是否允许超分配" header-align="center" align="center">
				<template #default="scope">
					<el-checkbox v-model="scope.row.overallocatepicks" disabled></el-checkbox>
				</template>
			</el-table-column>
			<el-table-column prop="uomlevel" label="计量单位" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.uomlevel" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in uomList" :key="item.list" :label="item.listname" :value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="locationtype" label="库位类型" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.locationtype" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in locTypeList" :key="item.list" :label="item.listname"
							:value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="locationcategory" label="库位类别" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.locationcategory" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in locCategoryList" :key="item.list" :label="item.listname"
							:value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<!-- <el-table-column prop="locationabc" label="库位ABC" header-align="center" align="center"></el-table-column> -->
			<el-table-column prop="allocationzone" label="分配区" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.allocationzone" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in zoneList" :key="item.zonecode" :label="item.zonename"
							:value="item.zonecode">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="groupuompicks" label="按计量单位和库位创建一项拣货任务" header-align="center" align="center">
				<template #default="scope">
					<el-checkbox v-model="scope.row.groupuompicks" disabled></el-checkbox>
				</template>
			</el-table-column>
			<!-- <el-table-column prop="lpnqtyconsidered" label="托盘数量" header-align="center" align="center">
			</el-table-column> -->
			<el-table-column prop="sort1" label="分类1" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.sort1" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in sortList" :key="item.list" :label="item.listname" :value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="sort2" label="分类2" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.sort2" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in sortList" :key="item.list" :label="item.listname" :value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="sort3" label="分类3" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.sort3" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in sortList" :key="item.list" :label="item.listname" :value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<el-table-column prop="sort4" label="分类4" header-align="center" align="center">
				<template #default="scope">
					<el-select v-model="scope.row.sort4" disabled>
						<el-option label="--" value=""></el-option>
						<el-option v-for="item in sortList" :key="item.list" :label="item.listname" :value="item.list">
						</el-option>
					</el-select>
				</template>
			</el-table-column>
			<!-- <el-table-column prop="lpnquantitysorttype" label="托盘数量分类规则" header-align="center" align="center">
			</el-table-column> -->
			<!-- <el-table-column prop="adduser" label="创建人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="addtime" label="创建时间"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatuser" label="更新人"  header-align="center"
                                           align="center"></el-table-column>
                                                    <el-table-column prop="updatetime" label="更新时间"  header-align="center"
                                           align="center"></el-table-column> -->
			<el-table-column label='操作' fixed="right" header-align="center" align="center" width="150">
				<template #default="scope">
					<el-button type="text" size="small"
						@click="addOrUpdateallocationstrategydetailHandleFn(scope.row.id)" v-if="hasPermission('lswms:allocationstrategy:update')" >修改</el-button>
					<el-button type="text" size="small" @click="deleteHandle(scope.row.id)" v-if="hasPermission('lswms:allocationstrategy:delete')">删除</el-button>
				</template>
			</el-table-column>
		</el-table>
		<el-pagination :current-page="page" :page-sizes="[10, 20, 50, 100]" :page-size="limit" :total="total"
			layout="total, sizes, prev, pager, next, jumper" @size-change="pageSizeChangeHandle"
			@current-change="pageCurrentChangeHandle">
		</el-pagination>
		<!-- 弹窗, 新增 / 修改 -->
		<allocationstrategydetailAddOrUpdate v-if="addOrUpdateVisible" ref="addOrUpdate"
			@refresh-data-list="getDataList"></allocationstrategydetailAddOrUpdate>
	</el-dialog>
	<!-- </div>
                </el-card>
            </div>
        </div>
    </div> -->
</template>

<script>
	import DataList from "@/utils/DataList";
	import {
		ref,
		reactive,
		onMounted,
		nextTick
	} from 'vue';
	import allocationstrategydetailAddOrUpdate from "@/components/lswms/base/AllocationstrategydetailAddOrUpdate";
	import {
		getCodeListByCode
	} from "@/network/lswms/base/Codelist.js"
	import {
		getzonelist
	} from "@/network/lswms/base/Zone.js"
	import {hasPermission} from "@/utils/hasPermission"
	export default {
		name: "allocationstrategydetail",

		components: {
			allocationstrategydetailAddOrUpdate,
		},

		setup() {
			const {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate
			} = DataList();



			onMounted(() => {
				mixinViewModuleOptions.value.getDataListIsPage = true;
				mixinViewModuleOptions.value.getDataListURL = '/lswms/allocationstrategydetail/page';
				mixinViewModuleOptions.value.deleteURL = '/lswms/allocationstrategydetail';
				mixinViewModuleOptions.value.exportURL = '/lswms/allocationstrategydetail/export';
				mixinViewModuleOptions.value.deleteIsBatchKey = 'id';
				mixinViewModuleOptions.value.deleteIsBatch = true
				if (mixinViewModuleOptions.value.activatedIsNeed) {
					getDataList();
				}
				dataForm.value = {
					id: '',
					strategykey: ''

				}
				locTypeFn();
				locCategoryFn();
				getZoneListFn();
				uomFn();
				sortFn();
			})

			const visible = ref(false);
			const init = () => {
				visible.value = true;
				nextTick(function() {
					//  dataFormRef.value.resetFields();
					// roleIdListDefault.value = [];
					if (dataForm.value.strategykey) {
						dataForm.value.id = '';
						getDataList()
					}

				})
			}


			//获取库位类型
			const locTypeList = ref("");
			const locTypeFn = () => {
				getCodeListByCode('loc_type').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					locTypeList.value = res.data;
				}).catch((err) => {});
			}
			//获取库位类别
			const locCategoryList = ref("");
			const locCategoryFn = () => {
				getCodeListByCode('loc_category').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					locCategoryList.value = res.data;
				}).catch((err) => {});
			}

			const uomList = ref("");
			const uomFn = () => {
				getCodeListByCode('UOMLEVEL').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					uomList.value = res.data;
				}).catch((err) => {});
			}

			const sortList = ref("");
			const sortFn = () => {
				getCodeListByCode('STRATEGYSORT').then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					sortList.value = res.data;
				}).catch((err) => {});
			}

			const zoneList = ref({});
			const getZoneListFn = () => {
				getzonelist().then((res) => {
					if (res.code !== 0) {
						return ElMessage.error(res.msg);
					}
					zoneList.value = res.data;
				}).catch((err) => {});
			}


			// 新增 / 修改
			const addOrUpdateallocationstrategydetailHandleFn = (id) => {
				//
				addOrUpdateVisible.value = true;
				nextTick(function() {
					addOrUpdate.value.dataForm.id = id;
					addOrUpdate.value.dataForm.strategykey = dataForm.value.strategykey;
					addOrUpdate.value.init();
				})
			}

			return {
				dataForm,
				mixinViewModuleOptions,
				getDataList,
				dataList,
				total,
				page,
				limit,
				dataListLoading,
				dataListSelectionChangeHandle,
				dataListSortChangeHandle,
				pageSizeChangeHandle,
				pageCurrentChangeHandle,
				addOrUpdateHandle,
				deleteHandle,
				exportHandle,
				addOrUpdateVisible,
				dataListSelections,
				addOrUpdate,
				visible,
				init,
				addOrUpdateallocationstrategydetailHandleFn,
				zoneList,
				locTypeList,
				locCategoryList,
				uomList,
				sortList
			}
		},
		methods:{
			hasPermission
		}
	}
</script>

<style scoped>

</style>
